<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="__TEMPLATE__/webfile/css/main.css">
    <link rel="stylesheet" type="text/css" href="__TEMPLATE__/webfile/css/common.css" />
    <link rel="stylesheet" type="text/css" href="__TEMPLATE__/webfile/css/dai.css" />
    <link rel="stylesheet" href="__TEMPLATE__/webfile/css/bootstrap.min.css">
</head>
<script src="__TEMPLATE__/webfile/js/jquery.js"></script>
<script src="__TEMPLATE__/webfile/js/bootstrap.min.js"></script>
<body>
<div class="main usercenter w">
    <div class="user_gamerecord w">
        <div class="user_right right " style="width: 100%">
            <div class="user_main">
                <div class="tabbable"> <!-- Only required for left/right tabs -->
                    <ul class="nav nav-tabs" style="padding-top: 5px;padding-left: 5px;height: 40px">
                        <li class="active"><a href="#tab1" data-toggle="tab" class="badge badge-inversee" style="height: 23px">修改密码</a></li>
                    </ul>
                    <ul class="nav nav-tabs" style="padding-top: 5px;padding-left: 5px;height: 40px;position:fixed;top:0;z-index: 5;width: 100%">
                        <li class="active"><a href="#tab1" data-toggle="tab" class="badge badge-inversee" style="height: 23px">修改密码</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab1">
                            <!--修改密码　　-->
                            <div class="user_body ">
                                <form class="form-horizontal" style="margin-top: 50px">
                                    <div class="control-group st1">
                                        <label class="control-label" for="oldPass">旧&nbsp;密&nbsp;码：</label>
                                        <div class="controls">
                                            <input type="password" id="oldPass" placeholder="旧密码" name="oldPass">
                                        </div>
                                        <div class="alert" style="position: absolute;top:0px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="newPass">新&nbsp;密&nbsp;码：</label>
                                        <div class="controls">
                                            <input type="password" id="newPass" placeholder="新密码" name="newPass">
                                        </div>
                                        <div class="alert" style="position: absolute;top:165px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong> <span></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label" for="rePass">重复密码：</label>
                                        <div class="controls">
                                            <input type="password" id="rePass" placeholder="重复密码" name="oldPasse">
                                        </div>
                                        <div class="alert" style="position: absolute;top:215px;left:410px;margin: auto;height: 13px;line-height: 13px">
                                            <strong>Warning!</strong><span></span>
                                        </div>
                                    </div>
                                    <div class="st1" id="password-way">
                                        <label class="radio" style="float: left;margin-left: 160px">
                                            <input type="radio" name="optionsRadios" id="optionsRadios1" value="1" checked>
                                            登录密码
                                        </label>
                                        <label class="radio" style="float: left;margin-left: 30px">
                                            <input type="radio" name="optionsRadios" id="optionsRadios2" value="2">
                                            取款密码
                                        </label>
                                    </div>
                                    <div class="control-group">
                                        <!--提交提示-->
                                        <div class="alert alert-success pos" id="pos1">
                                            <strong>提交成功！</strong>
                                        </div>
                                        <div class="alert alert-infos pos" id="pos2">
                                            <strong>提交失败！</strong>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <div style="margin-left: 100px;color: #C09853;margin-top: -10px">备注说明：</br>下线的返点不能高于或者等于本身的返点！</div>
                                        <div  style="height: 30px;margin-top: 20px;width: 100px;margin-left:220px; box-shadow:0 0 10px rgba(0,0,0,0.4);text-align:center;border-radius: 5px;background: #F4F4F4;line-height:30px;" id="submit">
                                            确定
                                        </div>
                                    </div>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>


</body>
<script>
    $(document).ready(function(){
//用户名校验
        var oldPass=false;
        var newPass=false;
        var rePass=false;
        var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
        var reg2= new RegExp("^[a-z]");

//旧密码校验
        $("#oldPass").blur(function() {
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            oldPass=false;
            var that1=$(this).parent().siblings('.alert');
            var that2=$(this).parent().siblings('.alert').children('span').get(0);
            that1.css({'display':'block'})
            if($(this).val().trim()===''){
                that2.innerText='密码不能为空！'
            }else if(!reg2.test($(this).val())){
                that2.innerText='密码请以字母开头';
            }else if(reg.test($(this).val())){
                that2.innerText='密码不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=20){
                that2.innerText='密码长度在5-20之间';
            }else{
                oldPass=true;
                that1.css({'display':'none'})
                that2.innerText=''
            }
        });
//新密码校验
        $("#newPass").blur(function() {
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            newPass=false;
            var that1=$(this).parent().siblings('.alert');
            var that2=$(this).parent().siblings('.alert').children('span').get(0);
            if($(this).val().trim()===''){
                that1.css({'display':'block'})
                that2.innerText='密码不能为空！'
            }else if(!reg2.test($(this).val())){
                that1.css({'display':'block'})
                that2.innerText='密码请以字母开头';
            }else if(reg.test($(this).val())){
                that1.css({'display':'block'})
                that2.innerText='密码不能为汉字';
            }else if($(this).val().length<=5||$(this).val().length>=20){
                that1.css({'display':'block'})
                that2.innerText='密码长度在5-20之间';
            }else{
                newPass=true;
                that1.css({'display':'none'})
                that2.innerText=''
            }
        });
//重复密码校验(2)
        $("#rePass").blur(function() {
            $("#pos1").css({'display':'none'});
            $("#pos2").css({'display':'none'});
            rePass=false;
            var that1=$(this).parent().siblings('.alert');
            var that2=$(this).parent().siblings('.alert').children('span').get(0);
            if($(this).val().trim()===''){
                that1.css({'display':'block'})
                that2.innerText='密码不能为空！'
            }else if($(this).val()!=$('#newPass').val()){
                that1.css({'display':'block'})
                that2.innerText='密码不一致';
            }
            else{
                rePass=true;
                that1.css({'display':'none'})
                that2.innerText=''
            }
        });

        $('#submit').eq(0).click(function(){
            if(oldPass===true&&newPass===true&&rePass===true){
//获取付款方式的内容
                var dd='';
                function pay(){
                      $("#password-way input").each(function (index,value) {
                          if(value.checked==true){
                             dd=$(this).val();
                          }
                      })
                      return dd
                }
// 拼接传送数据格式
                var aa= {"oldPass":$("#oldPass").val(),"newPass":$("#newPass").val(),"oldPasse":$("#rePass").val(),"way": pay()}
                $.ajax({
                    url:"{:url('agent/updatePassd')}",
                    type:"POST",
                    data:aa,
                    success: function(data) {
                        if(data=="ok"){
                            $('#pos1').css({'display':'block'});
                        }else{
                            $('#pos2').css({'display':'block'});
                        }
                    }
                });
                $('#pos1').css({'display':'block'});//测试
            }else{
                $('#pos2').css({'display':'block'});
            }
        })



    })
</script>
</html>